import React, { Component } from 'react'
import {Modal,Form,Input,message} from 'antd';
import axios from 'axios';
import EditForm from './EditNorForm';

export default class EditUser extends Component {
    editForm=null;//报错
    handleEditUser=()=>{
        const {validateFields}=this.editForm.formRef.current;
        // console.log(validateFields);
        validateFields()
        .then((values)=>{
            //提交表单

            let oldval= {...this.props.data};
            this.props.edituser(oldval,values);

            message.info('修改成功')
            this.props.close();
        }).catch(errorInfo=>{
            message.error('修改失败！');
        })
        }
   
    render() {
        return (
            <Modal
                destroyOnClose
                title="修改用户"
                visible={this.props.visible}
                okText="修改"
                cancelText="取消"
                onCancel={()=>{this.props.close()}}
                onOk={this.handleEditUser}
                >
                <EditForm ref={frm=>this.editForm=frm} data={this.props.data}></EditForm>
            </Modal>
        )
    }
}
